import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:vc_package/widget/extension.dart';
import 'package:vc_package/widget/text_view.dart';

import '../utils/base_color_utils.dart';
import 'clickable.dart';

class ActionButton extends StatelessWidget {
  const ActionButton(
    this.text, {
    super.key,
    this.radius,
    this.onTap,
    this.margin,
    this.bgColor,
    this.color,
    this.borderRadius,
    this.size,
    this.contentPadding,
    this.width,
    this.height,
    this.alignment,
  });

  final String? text;
  final Function()? onTap;
  final double? radius;
  final EdgeInsets? margin;
  final EdgeInsets? contentPadding;
  final Color? bgColor;
  final Color? color;
  final BorderRadiusGeometry? borderRadius;
  final double? size;
  final double? width;
  final double? height;
  final Alignment? alignment;

  @override
  Widget build(BuildContext context) {
    var c = Container(
      decoration: BoxDecoration(
        color: bgColor ?? ColorUtils.blue,
        borderRadius: borderRadius ?? BorderRadius.all(radius.radius),
      ),
      width: width,
      height: height,
      child: TextView(
        text,
        fontWeight: FontWeight.w600,
        size: size ?? 16.fit,
        color: color ?? Colors.white,
        padding: contentPadding ?? EdgeInsets.zero,
        alignment: alignment ?? Alignment.center,
      ),
    );

    return null == onTap
        ? c
        : Clickable(
            radius: radius ?? 2.fit,
            onTap: onTap,
            margin: margin ?? EdgeInsets.zero,
            bgColor: ColorUtils.transparent,
            child: c,
          );
  }
}
